using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;

namespace AUV_SUT_1_Demo_Software
{
    public partial class Form1 : Form
    {
        VideoCapture capture;
        public Form1()
        {
            InitializeComponent();
            
        }
        
        private void Run()
        {
            try
            {
                imageBox1.Visible = true;
                capture = new VideoCapture();
            }
            catch (Exception Ex)
            {

                MessageBox.Show(Ex.Message);
                return;
            }
            Application.Idle += ProcessFrame;
        }

        private void ProcessFrame(object sender, EventArgs e)
        {
            
            imageBox1.Image = capture.QuerySmallFrame();
        }

        public string x;
        

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {
            Form2 openform = new Form2();
            openform.Show();
        }

        private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("The clips of AUV SUT-1 is available at 'www.abolfazlm.com/resume.php'. You need to download video clips from there first."+
                "\nThen you should choose downloaded video files from 'Open Video Clip' button and then you should press 'Play Video Clip' button.", "Where is Clip?");
        }

        private void button7_Click(object sender, EventArgs e)
        {
            WMP1.URL = x;
            WMP1.Ctlcontrols.play();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            OpenFileDialog openfiledialog1 = new OpenFileDialog();

            if(openfiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                x = openfiledialog1.FileName.ToString();
            }
          
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Run();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            imageBox1.Visible = false;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown1.Value = 5;
            numericUpDown1.Enabled = true;
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            
            progressBar1.Value = (int)numericUpDown1.Value;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown1.Value = 0;
            numericUpDown1.Enabled = false;
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown2.Value = 5;
            numericUpDown2.Enabled = true;
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown2.Value = 0;
            numericUpDown2.Enabled = false;
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown3.Value = 5;
            numericUpDown3.Enabled = true;
        }

        private void radioButton6_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown3.Value = 0;
            numericUpDown3.Enabled = false;
        }

        private void radioButton7_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown4.Value = 5;
            numericUpDown4.Enabled = true;
        }

        private void radioButton8_CheckedChanged(object sender, EventArgs e)
        {
            numericUpDown4.Value = 0;
            numericUpDown4.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            numericUpDown1.Value = 5;
            numericUpDown2.Value = 5;
            numericUpDown3.Value = 5;
            numericUpDown4.Value = 5;
            radioButton1.Checked = true;
            radioButton3.Checked = true;
            radioButton5.Checked = true;
            radioButton7.Checked = true;
            numericUpDown1.Enabled = true;
            numericUpDown2.Enabled = true;
            numericUpDown3.Enabled = true;
            numericUpDown4.Enabled = true;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            numericUpDown1.Value = 0;
            numericUpDown2.Value = 0;
            numericUpDown3.Value = 0;
            numericUpDown4.Value = 0;
            radioButton2.Checked = true;
            radioButton4.Checked = true;
            radioButton6.Checked = true;
            radioButton8.Checked = true;
            numericUpDown1.Enabled = false;
            numericUpDown2.Enabled = false;
            numericUpDown3.Enabled = false;
            numericUpDown4.Enabled = false;

        }

        private void progressBar1_Click(object sender, EventArgs e)
        {
            
        }

        private void numericUpDown2_ValueChanged(object sender, EventArgs e)
        {
            progressBar2.Value = (int)numericUpDown2.Value;
        }

        private void numericUpDown3_ValueChanged(object sender, EventArgs e)
        {
            progressBar3.Value = (int)numericUpDown3.Value;
        }

        private void numericUpDown4_ValueChanged(object sender, EventArgs e)
        {
            progressBar4.Value = (int)numericUpDown4.Value;
        }

        private void label1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("http://abolfazlm.com/");
        }
    }
}
